import request from "@/assets/js/request";
import util from "@/assets/js/public";
import { getToken } from '@/assets/js/auth';
import Vue from "vue";

//获取用户信息
export function getUserdata(params){
    console.log('获取用户信息时的名字是：'+params.userName);
    return request(
        {
            url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/getCurrentUser$sso',
            contentType: 'application/json;charset=UTF-8',
            data:{
                "access_token":getToken(),
                "appCode":"yglt",
                "noAction": "1",
                "versionName":"2.7.92",
                    "kv":{
                        "versionName":"2.7.92",
                        "versionCode":2079200,
                        "appcode":"yglt",
                        "currentUserCode":util.encrypt(params.userName),
                    }
            }
        }
    )
}

export function uploadProcessFiles(fd,params){
    console.log('CCCCCCCCCC'+process.env.VUE_APP_UPFILE)
    return request({
        url:process.env.VUE_APP_URL+'/action/openapi/bps/common/uploadCompressImages2?pmInsType=A&pmInsTypePart=1&appcode=yglt&currentUserCode='
        +util.encrypt(params.userName)+'&access_token='+getToken(),
        contentType:'multipart/form-data',
        data:fd,
        catch:true
    })
}
export function uploadProcessFilesYglt(fd,params){
  return request({
    url:process.env.VUE_APP_URL+'/action/openapi/bps/common/uploadCompressImages2?pmInsType=A&pmInsTypePart=1&appcode=yglt&currentUserCode='
    +util.encrypt(params.userName)+'&access_token='+getToken(),
    contentType:'multipart/form-data',
    data:fd,
    catch:true
  })
}

//保存政策宣讲工单的表格
export function saveZcxjFromDetail(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/usPantchDetail$api$insertUsPantchDetail?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            },
            "jsonName":'appDecision',
            "appDecision":params.fromdetaildata
        }
    })
}
//废弃，获取下方四个栏目标题，重复
export function findParentCategory(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$category$api$findParentCategory?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            }
        }
    })
}
//获取首页前两个栏目内容
export function findAllBoutique(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$content$api$findAllBoutique?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            }
        }
    })
}
//获取首页后四个栏目内容
export function findAllIndex(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$content$api$findAllIndex?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
                "direction":params.listQuery.direction,
                "properties":params.listQuery.properties,
            },
            "jsonName":'appDecision',
            "appDecision":params.fromdetaildata
        }
    })
}
//获取当前登录人信息，头像等
export function findCurrentAccount(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$account$api$findCurrentAccount?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            }
        }
    })
}

//获取整体的登录信息等
export function loginCounts(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$account$api$loginCounts?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            }
        }
    })
}

//获取默认头像数组
export function getDefaultImg(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$account$api$getDefaultImg?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            }
        }
    })
}


//创建用户信息
export function create(params){
    return request({
        url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$account$api$create?source=MOBILE',
        contentType:'application/json;charset=UTF-8',
        data:{
            "access_token":getToken(),
            "appCode":"yglt",
            "currentUserCode":util.encrypt(params.userName),
            "versionName":"2.7.92",
            "source":'MOBILE',
            "noAction":'1',  
            "kv":{
                "currentUserCode":util.encrypt(params.userName),
                "source":'MOBILE',
                "isFlag":'1',
            },
            "jsonName":'appDecision',
            "appDecision":{
                "nickname":params.nickname,
                "imgId":params.imgId,
                "oaAccount":util.encrypt(params.userName),
            }
        },
    })
}
//获取我的帖子列表
export function findMyContent(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$content$api$findMyContent?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "page":params.page,
                  "rows":params.rows,
                  "size":params.size,
                  "direction":'desc',
                  "properties":'isTop,modifiedTime',
                  "currentUserCode":util.encrypt(params.userName),
              },
              "jsonName":'appDecision',
              "appDecision":{
                  "creator":params.userName,
              }
          }
      }
  )
}

//获取我的评论列表
export function findMyComment(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$comment$api$findMyComment?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "page":params.page,
                  "rows":params.rows,
                  "size":params.size,
                  "direction":params.direction,
                  "properties":params.properties,
                  "currentUserCode":util.encrypt(params.userName),
              },
              "jsonName":'appDecision',
              "appDecision":{
                  "creator":params.userName,
              }
          }
      }
  )
}

//获取我的关注列表
export function findAllByFromName(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$interest$api$findAllByFromName?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "page":params.page,
                  "rows":params.rows,
                  "size":params.size,
                  "name":params.userName,
                  "currentUserCode":util.encrypt(params.userName),
              },
              // "jsonName":'appDecision',
              // "appDecision":{
              //     "creator":params.userName,
              // }
          }
      }
  )
}

//获取我的粉丝列表
export function findAllByToName(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$interest$api$findAllByToName?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "page":params.page,
                  "rows":params.rows,
                  "size":params.size,
                  "name":params.userName,
                  "currentUserCode":util.encrypt(params.userName),
              },
              // "jsonName":'appDecision',
              // "appDecision":{
              //     "creator":params.userName,
              // }
          }
      }
  )
}

//获取我的粉丝列表
export function deleteById1(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$content$api$deleteById1?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "id":params.id,
                  "currentUserCode":util.encrypt(params.userName),
              },
              // "jsonName":'appDecision',
              // "appDecision":{
              //     "id":params.id,
              // }
          }
      }
  )
}

//修改评论
export function update(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$comment$api$update?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "id":params.id,
                  "content":params.content,
                  "currentUserCode":util.encrypt(params.userName),
              },
              "jsonName":'appDecision',
              "appDecision":{
                  "id":params.id,
                  "content":params.content,
              }
          }
      }
  )
}

//删除单条评论
export function deleteById(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$comment$api$deleteById?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "id":params.id,
                  "currentUserCode":util.encrypt(params.userName),
              }
          }
      }
  )
}

//取消关注某人
export function interestdelete(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$interest$api$delete1?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "currentUserCode":util.encrypt(params.userName),
              },
              "jsonName":'appDecision',
              "appDecision":{
                  "toName":params.toName,
                  // "fromName":params.fromName,
              }
          }
      }
  )
}

//关注某人
export function interestcreate(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$interest$api$create1?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "currentUserCode":util.encrypt(params.userName),
              },
              "jsonName":'appDecision',
              "appDecision":{
                  "toName":params.toName,
                  "fromName":params.fromName,
              }
          }
      }
  )
}

//发帖
export function contentcreate(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$content$api$create1?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "currentUserCode":util.encrypt(params.userName),
              },
              "jsonName":'appDecision',
              "appDecision":params.fromdata
          }
      }
  )
}

//获取更多回复
export function findComment2(params){
  return request (
      {
          url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'us$comment$api$findComment2?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data:{
              "access_token":getToken(),
              "appCode":"yglt",
              "currentUserCode":util.encrypt(params.userName),
              "versionName":"2.7.92",
              "source":'MOBILE',
              "noAction":'1',
              "kv":{
                  "source":'MOBILE',
                  "currentUserCode":util.encrypt(params.userName),
                  "contentId":params.contentId,
                  "rootId":params.rootId,
              },
              "jsonName":'appDecision',
              "appDecision":{
                "contentId":params.contentId,
                "rootId":params.rootId,
                "direction":'desc',
                "properties":'isTop,modifiedTime',
                "page":'1',
                "size":'100',
              }
          }
      }
  )
}
//获取首页每个栏目详细数据
export function findAllMenu(params){
  return request({
      url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$content$api$findAllMenu?source=MOBILE',
      contentType:'application/json;charset=UTF-8',
      data:{
          "access_token":getToken(),
          "appCode":"yglt",
          "currentUserCode":util.encrypt(params.userName),
          "versionName":"2.7.92",
          "source":'MOBILE',
          "noAction":'1',  
          "kv":{
              "currentUserCode":util.encrypt(params.userName),
              "source":'MOBILE',
              "isFlag":'1',
          }
      }
  })
}
//获取首页每个栏目详细数据
export function queryMenuContent(params){
  return request({
      url:process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/us$content$api$queryMenuContent?source=MOBILE',
      contentType:'application/json;charset=UTF-8',
      data:{
          "access_token":getToken(),
          "appCode":"yglt",
          "currentUserCode":util.encrypt(params.userName),
          "versionName":"2.7.92",
          "source":'MOBILE',
          "noAction":'1',  
          "kv":{
              "currentUserCode":util.encrypt(params.userName),
              "source":'MOBILE',
              "isFlag":'1',
              "id":params.id,
              "size":'5',
          }
      }
  })
}